package com.santu.edu.supporter.biz.order.kd.pojo.dto;

import com.santu.edu.supporter.biz.order.common.pojo.enums.OrderStatusEnum;
import com.santu.edu.supporter.biz.order.kd.pojo.enums.KdGoodTypeEnum;
import com.santu.edu.supporter.biz.order.kd.pojo.enums.KdProcessTypeEnum;
import com.santu.edu.supporter.biz.order.kd.pojo.params.KdOrderAddParam;
import com.santu.edu.supporter.biz.order.kd.pojo.params.KdOrderUpdateParam;
import com.santu.edu.supporter.biz.order.kd.pojo.po.KuaidiOrderPO;
import lombok.Data;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

/**
 * @author luoyaoqi
 * @createTime 2024/2/21
 * @description
 */
@Data
@Accessors(chain = true)
public class KdOrderDTO{

    /**
     * 学校id
     */
    private String schoolId;

    /**
     * 订单号
     */
    private String orderId;

    /**
     * 用户id(发起人)
     */
    private String userId;

    /**
     * 快递点id
     */
    private String buildingsId;

    /**
     * 购买的商品信息
     */
    private String goodInfo;

    /**
     * 商品图片地址
     */
    private String imageUrl;

    /**
     * 商品类型[0:小件,1:中件,3:大件]
     */
    private KdGoodTypeEnum goodType;

    /**
     * 价钱
     */
    private BigDecimal price;

    /**
     * 备注信息
     */
    private String remarkInfo;

    /**
     * 送货地址id
     */
    private String addressId;

    /**
     * 订单状态
     */
    private OrderStatusEnum orderType;

    /**
     * 货物状态
     */
    private KdProcessTypeEnum processType;

    /**
     * 送达照片
     */
    private String sendGoodImage;

    public static KdOrderDTO createItem(String orderId,KdOrderAddParam addParam) {
        return new KdOrderDTO()
                .setOrderId(orderId)
                .setBuildingsId(addParam.getBuildingsId())
                .setGoodInfo(addParam.getGoodInfo())
                .setImageUrl(addParam.getImageUrl())
                .setGoodType(KdGoodTypeEnum.convert(addParam.getGoodType()))
                .setPrice(addParam.getPrice())
                .setRemarkInfo(addParam.getRemarkInfo())
                .setAddressId(addParam.getAddressId())
                .setOrderType(OrderStatusEnum.TO_BE_PAID)
                .setProcessType(KdProcessTypeEnum.WAIT_FOR_PICKUP);
    }


    public static KdOrderDTO createItem(KdOrderUpdateParam updateParam) {
        return new KdOrderDTO()
                .setOrderId(updateParam.getOrderId())
                .setAddressId(updateParam.getAddressId());
    }

    public static KdOrderDTO createItem(KuaidiOrderPO item) {
        return new KdOrderDTO()
                .setOrderId(item.getOrderId())
                .setOrderType(OrderStatusEnum.convert(item.getOrderType()))
                .setProcessType(KdProcessTypeEnum.convert(item.getProcessType()))
                .setSchoolId(item.getSchoolId())
                .setUserId(item.getUserId())
                .setBuildingsId(item.getBuildingsId())
                .setGoodInfo(item.getGoodInfo())
                .setImageUrl(item.getImageUrl())
                .setGoodType(KdGoodTypeEnum.convert(item.getGoodType()))
                .setPrice(item.getPrice())
                .setRemarkInfo(item.getRemarkInfo())
                .setAddressId(item.getAddressId())
                .setSendGoodImage(item.getSendGoodImage());

    }
}
